package com.java1234.dao;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

import com.java1234.util.DButil;

public class RoomDao {
	public ResultSet getallroom(Connection c) throws SQLException
	{
		String sql="select Rno,Rname,Rposition,Rlevel,Rsize,Mname "
				+ "from room,manager where room.Mno=manager.Mno";
		PreparedStatement pstmt=c.prepareStatement(sql);
		ResultSet rs=pstmt.executeQuery();
		return rs;
	}
	public ResultSet getroom_name(Connection c,String s1) throws SQLException
	{
		String sql="select Rno,Rname,Rposition,Rlevel,Rsize,Mname "
				+ "from room,manager where room.Mno=manager.Mno and Rname=?";
		PreparedStatement pstmt=c.prepareStatement(sql);
		pstmt.setString(1, s1);
		ResultSet rs=pstmt.executeQuery();
		return rs;
	}
	public ResultSet getroom_rno(Connection c,String s1) throws SQLException
	{
		String sql="select Rno,Rname,Rposition,Rlevel,Rsize,Mname "
				+ "from room,manager where room.Mno=manager.Mno and Rno=?";
		PreparedStatement pstmt=c.prepareStatement(sql);
		pstmt.setString(1, s1);
		ResultSet rs=pstmt.executeQuery();
		return rs;
	}
	public ResultSet getroom_level(Connection c,String s1) throws SQLException
	{
		String sql="select Rno,Rname,Rposition,Rlevel,Rsize,Mname "
				+ "from room,manager where room.Mno=manager.Mno and Rlevel=?";
		PreparedStatement pstmt=c.prepareStatement(sql);
		pstmt.setString(1, s1);
		ResultSet rs=pstmt.executeQuery();
		return rs;
	}
	public ResultSet getroom_size(Connection c,String s1) throws SQLException
	{
		String sql="select Rno,Rname,Rposition,Rlevel,Rsize,Mname "
				+ "from room,manager where room.Mno=manager.Mno and Rsize>=?";
		PreparedStatement pstmt=c.prepareStatement(sql);
		pstmt.setString(1, s1);
		ResultSet rs=pstmt.executeQuery();
		return rs;
	}
	public ResultSet getroom_ls(Connection c,String s1,String s2) throws SQLException
	{
		String sql="select Rno,Rname,Rposition,Rlevel,Rsize,Mname "
				+ "from room,manager where room.Mno=manager.Mno and Rlevel=? and Rsize>=?";
		PreparedStatement pstmt=c.prepareStatement(sql);
		pstmt.setString(1, s1);
		pstmt.setString(2, s2);
		ResultSet rs=pstmt.executeQuery();
		return rs;
	}
	/*public static void test() throws ClassNotFoundException, SQLException
	{
		Connection c=null;
		DButil db=new DButil();
		c=db.getcon();
		String a=">10 and Rsize<100";
		String sql="select * from room where Rsize"+a;
		PreparedStatement pstmt=c.prepareStatement(sql);
		ResultSet rs=pstmt.executeQuery();
		while(rs.next())
		{
			System.out.println(rs.getString("Rno"));
		}
		c.close();
	}
	public static void main(String[] agrs)
	{
		try {
			test();
		} catch (ClassNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}*/
}
